<template>
	<scroll ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
		<stop isBack>
			<view slot="content">审批管理</view>
		</stop>
		<view class="flrc bcf">
			<!-- <stab :names="['全部','发票',]"></stab> -->
			<sentity model="ProjectPointStatus" v-model="status" label="审批状态" placeholder="请选择" class="flex1 pad1 marlr3"></sentity>
			<sentity model="ProjectPointType" v-model="type" label="审批类型" placeholder="请选择" class="flex1 pad1 marlr3"></sentity>
		</view>
		<view class="bg-green light tac pad2">选择相应条件筛选</view>
		<view>
			<view v-if="list.length == 0" class="tac pad5 mar3 bdda bcf">
				暂无数据
			</view>
			<view class="bcf pad2 mar3 bdso lh2" v-for="item in list">
				<view class="flrc pad1">
						<view class="flex1 fwb">【{{item.project.name}}】</view>
						<view><status :item="item.status"></status></view>
				</view>
				<view class="flrc bdtda pad1">
					<view>资料类型：</view>
					<view class="flex1 tar">{{item.type.name}}</view>
				</view>
				<view class="flrc bdtda pad1">
					<view>上传时间：</view>
					<view class="flex1 tar">{{datetime(item.upAt)}}</view>
				</view>
				<view class="flrc bdtda pad1">
					<view>回传时间：</view>
					<view class="flex1 tar">{{datetime(item.backAt)}}</view>
				</view>
				<view>
					<view class="list-style-2 martb2">上传文件</view>
					<view class="mar2 pad2 bc13 bdda round3">备注：{{item.tips}}</view>
					<view>
						<a class="flrc pad1 bdda mar2 bc13 pos-r" :href="$api.aroot() + file.file" v-for="file,index in item.upFiles">
							<view class="flex1">文件（{{index+1}}）：{{file.name}}</view>
							<!-- <a class="table-btn" :href="$api.aroot() + file.file" target='_blank'>下载入口</a> -->
							<!-- <view class="fa fa-cloud-download c01"></view> -->
							<ripple></ripple>
						</a>
					</view>
				</view>
				<view>
					<view class="list-style-2 martb2">回传文件</view>
					<view class="mar2 pad2 bc13 bdda round3" v-show="isbool(item.backMessage)">备注：{{item.backMessage}}</view>
					<view>
						<!-- <view class="flrc pad1 bdda mar2 bc13 pos-r" @tap="download(file.file)" v-for="file in item.upFiles"> -->
						<a class="flrc pad1 bdda mar2 bc13 pos-r" :href="$api.aroot() + file.file" v-for="file,index in item.backFiles">
							<view class="flex1">>文件（{{index+1}}）：{{file.name}}</view>
							<!-- <view class="fa fa-cloud-download c01"></view> -->
							<ripple></ripple>
						</a>
					</view>
				</view>
			</view>
		</view>
	</scroll>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import ProjectPoint from "@/models/user/ProjectPoint.js";
	let pp = new ProjectPoint()
	export default {
		mixins:[MescrollMixin],
		data() {
			return {
				status:'',
				type:'',
				list:[]
			}
		},
		methods: {
			download(path){
				// this.$api.download(path,res=>{
				// 	this.log(res)
				// })
				this.goto(path)
			}
			,reload(){
				let status = ''
				if(this.isbool(this.status)){
					status = '/api_/project_statuses/' + this.status
				}
				let type = ''
				if(this.isbool(this.type)){
					type = '/api_/project_types/' + this.type
				}
				pp.setWhere({
					eq:{
						status:this.status,type:this.type
					}
				}).setMy().reload()
			}
		},
		mounted() {
			pp.init(this).setMy()
			.setGroup(['all']).setCbFunc(res=>{
					this.list = res
			}).getList()
		},
		onLoad() {
			// this.$api.get('/ez/api/ProjectPoint',{
			// 	_option:['my'],
			// 	_g:['all']
			// },res=>{
			// 	this.list = res.d
			// })
		},
		watch:{
			status(val){
				this.reload()
			},
			type(val){
				this.reload()
			}
		}
	}
</script>

<style>

</style>
